<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="${ctx}/css/common.css" />
<link rel="stylesheet" href="${ctx}/css/page.css" />
<link red="stylesheet" href="${ctx }/css/contractListFoePlat.css"/>
<link rel="stylesheet" href="${ctx}/css/iconfont.css"/>
<jsp:include page="../inc_bootstrap.jsp"></jsp:include>
<title>切位订单-更多详情</title>
<style>
	.bold{
		font-size:14px;
		text-weight:bold;
		color:#adadad;
	}
	.default{
		color:#34c0e3;
		border-bottom:2px solid #34c0e3;
	}
	.conditionList li{
		height:40px;
		line-height:40px;
	}
</style>

<script type="text/javascript">
	$(function(){
		//tab切换
		$(".bold").click(function(){
			$(".bold").css({
				"color":"#adadad",
				"border":"none"
			});
			$(this).css({
				"color":"#34c0e3",
				"border-bottom":"2px solid #34c0e3"
			});
            var id = $(this).attr("id");
            if(id == "tab1"){
                $("#detail").css({"display":"block"});
                $("#log").css({"display":"none"});
            }else{
                $("#log").css({"display":"block"});
                $("#detail").css({"display":"none"});
            }
        });
		var conStatus= ${param.conStatus};
		conStatus=CommonConverter.toContractStatusStr(conStatus);
		$("#conStatus").text(conStatus);//填充合同状态
        getData();
	});
    var pageNum = 1;
    function getData(){
        var param = {
            conNo:"${param.conNo}",
            page:pageNum,
            rows:20
        };
        $.get('${ctx}/search/getBuyerList?temp='+Math.random(),param,function(data){
            $('table tbody').empty();
            var str = "";
            for(var i=0;i<data.rows.length;i++){
                var obj = data.rows[i];
                var intervalDay=CommonConverter.toEmptyStr(obj.list[0].intervalDay);
                if(intervalDay != 0){
                    intervalDay ="+"+intervalDay;
                };
                var ticketRate="";
                if(obj.ticketRate!=obj.oldTicketRate){
                    ticketRate='<span class="pew">'+obj.ticketRate+'</span>'+'<br/>'+'<span style="text-decoration:line-through">'+obj.oldTicketRate+'</span>';
                }else{
                    ticketRate='<span class="pew">'+obj.ticketRate+'</span>';
                }
                var ticketLoss="";
                if(obj.ticketLoss!=obj.oldTicketLoss){
                    ticketLoss='<span class="pew">'+obj.ticketLoss+'</span>'+'<br/>'+'<span style="text-decoration:line-through">'+obj.oldTicketLoss+'</span>';
                }else{
                    ticketLoss='<span class="pew">'+obj.ticketLoss+'</span>';
                }
                var sellingPrice="";
                if(obj.oldSellingPrice!=obj.sellingPrice){
                    sellingPrice='<span class="pew">'+obj.sellingPrice+'</span>'+'<br/>'+'<span style="text-decoration:line-through">'+obj.oldSellingPrice+'</span>';
                }else{
                    sellingPrice='<span class="pew">'+obj.sellingPrice+'</span>'
                }
                var button = '<i class="icon iconfont center" title="日志" onclick=Log("'+obj.orderNumber+'")>&#xe609;</i>';
                if(obj.orderStatus == 4){
                    button +='<i class="icon iconfont position" title="名单" onclick=Look("'+obj.orderNumber+'")>&#xe603;</i>';
                }
                str+="<tr height='38px' class='reBorder'>"
                str+="	<td width='243' align='center'>订单号："+obj.orderNumber+"</td>"
                str+="	<td width='414' align='right' colspan='9'>"
                str+=button
                str+="	</td>"
                str+="</tr>"
                str+="<tr height='90px'>"
                str+="	<td width='160px' align='center'>"
                str+="		往：<span style='color:black;'>"+obj.list[0].airlineNumber+"</span><br/>"
                str+="		返：<span style='color:black;'>"+obj.list[1].airlineNumber+"</span>"
                str+="	</td>"
                str+="	<td width='208px' align='right'>"
                str+="		<span>"+CommonConverter.formatFlightTime((obj.list)[0].deptTime)+"</span><br/>"
                str+="		<span style='color:#444e50'>"+obj.list[0].deptCity+"</span><span style='color:#444e50'>("+obj.list[0].deptCode+")</span><span style='color:#e2615c'>"+obj.list[0].deptTerminal+"</span><br/>"
                str+= (obj.list.length==2) ?  "<span>"+CommonConverter.formatFlightTime((obj.list)[1].arrTime)+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td width='165px' align='center'>"
                str+="		<span style='color:#23b9dc'>"+obj.list[0].deptDate+"</span><br/>"
                str+= (obj.list.length==2) ?  "<img src='${ctx}/image/flightQuery/round.gif'>" :  "<img src='${ctx}/image/flightQuery/dancheng.png'>";
                str+= (obj.list.length==2) ?  "<br/><span style='color:#23b9dc'>"+obj.list[1].deptDate+"</span>" :  "";
                str+="	</td>"
                str+="	<td width='208px'>"
                str+="		<span>"+CommonConverter.formatFlightTime((obj.list)[0].arrTime)+"</span><span style='color:#e2615c;'>"+intervalDay+"<br/>"
                str+="		<span style='color:#444e50'>"+obj.list[0].arrCity+"</span><span style='color:#444e50'>("+obj.list[0].arrCode+")</span><span style='color:#e2615c'>"+obj.list[0].arrTerminal+"</span><br/>"
                str+= (obj.list.length==2) ?  "<span>"+CommonConverter.formatFlightTime((obj.list)[1].deptTime)+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td width='96px' align='center' style='color:#23b9dc'>"+sellingPrice+"</td>"
                str+="	<td width='151px' align='center' style='color:#e2615c'>"+obj.purchQuantity+"</td>"
                str+="	<td width='151px' align='center' style='color:#e2615c'>"+(obj.sellingPrice)*(obj.purchQuantity);+"</td>"
                str+="	<td width='151px' align='center' style='color:#e2615c'>"+CommonConverter.toOrderBizStatusStr(obj.orderStatus)+"</td>"
                str+="</tr> "
            }
            $('#tb').append(str);
            //显示分页
            layui.use(['laypage', 'layer'], function(){
                var laypage = layui.laypage;
                laypage({
                    cont: 'pager'
                    ,pages:  Math.ceil(data.total/20) //得到总页数 //总页数
                    ,groups: 5 //连续显示分页数
                    ,skin: '#1E9FFF'
                    ,curr : pageNum
                    ,jump: function(obj,first){
                        if(!first){
                            pageNum = obj.curr;
                            getData();
                        }
                    }
                });
            });

        });
    }
    //查看名单弹出框
    function Look(orderNumber) {
        //alert(orderNumber);
        layer.open({
            type: 2,
            title: ['订单管理-查看票号','background-color:#00B2EE; color:#fff;'],
            shadeClose: true,
            shade: 0.3,
            area: ['1020px', '500px'],
            content: ['${ctx}/order/orderTickets/'+orderNumber, 'no'], //iframe的url，no代表不显示滚动条
        });
    };

    //查看日志
    function Log(orderNumber){
        //alert(orderNumber);
        layer.open({
            type: 2,
            title: ['订单操作记录','background-color:#00B2EE; color:#fff;'],
            shadeClose: true,
            shade: 0.5,
            area: ['750px', '450px'],
            content: ['${ctx}/nporder/logs/'+orderNumber, 'no'],
            success: function(layero, index){
            },
            end:function(){
            }
        });
    };
</script>
</head>
<body>
	<jsp:include page="../head.jsp"></jsp:include>
			<div class="content">
                <ul class="list conditionList">
                    <li class="bold default" id="tab1">合同详情</li>
                    <li class="bold" id="tab2">合同日志</li>
                    <li class="right">
                        合同号：<span id="cashNo">${param.conNo}</span>
                    </li>
                    <li class="right">
                        合同状态：<span id="conStatus"></span>
                    </li>
                    <li class="right">
                        支付截止时间：<span id="payOverTime">${payOverTime}</span>
                    </li>
                </ul>
            <div id="detail" class="divBox">
			 	<table class="conTable">
			 		<thead>
			 			<tr height="38px" >
							<td width="128" align="center"><img src="${ctx }/image/flightQuery/flightNumber.gif">航班号</td>
							<td width="199" align="right"><img src="${ctx }/image/flightQuery/flightStart.gif">出发</td>
							<td width="169" align="center">&nbsp;&nbsp;&nbsp;</td>
							<td width="299"><img src="${ctx }/image/flightQuery/flightEnd.gif">到达</td>
							<td width="160" align="center">单价</td>
							<td width="134" align="center">数量</td>
							<td width="127" align="center">预定总价</td>
							<td width="86" align="center">状态</td>
						</tr>
			 		</thead>
					<tbody id="tb">

					</tbody> 
			</table>
            <!-- 分页 -->
            <div id="pager" class="divBox"></div>
        </div>
            <div id="log" class="divBox" style="display: none">
                <table id="reportTable"></table>
            </div>
	</div>
	<jsp:include page="../footer.jsp"></jsp:include>
    <script>
        $(function(){
            $('#reportTable').bootstrapTable({
                url:'${ctx}/log/contract?orderNo=${param.conNo}&temp='+Math.random(),
                dataType: "json",
                method: 'get',
                cache: false,
                height: "auto",//
                striped: true,
                pagination: false,
                pageSize: 500,
                pageNumber:1,
                pageList: [500],
                search: false,
                showColumns: true,
                showRefresh: true,
                clickToSelect: true,
                idField:'id',
                paginationHAlign: 'left',
                paginationDetailHAlign: 'right',
                sidePagination: "server", //表示服务端请求
                queryParamsType : "undefined",
                columns: [
                    {field:"id",title:"a",align:"left",valign:"middle",sortable:"true",visible:false},
                    {field:"operateName",title:"操作人",align:"left",valign:"middle",width:"100"},
                    {field:"operateRole",title:"角色",align:"left",valign:"middle",width:"100"},
                    {field:"operateTime",title:"操作时间",align:"left",valign:"middle",width:"100"},
                    {field:"operateState",title:"操作",align:"center",valign:"middle",width:"100"},
                    {field:"remarks",title:"备注",align:"center",valign:"middle",width:"200"}
                ],
                formatNoMatches: function(){
                    return '无符合条件的记录';
                }
            });
            $(window).resize(function () {
                $('#reportTable').bootstrapTable('resetView');
            });
        });
    </script>
</body>
</html>